<script setup lang="ts">
import { toRefs } from "vue";
import _ from "lodash";
import ComSwitchView from "@/components/ComSwitchView/index.vue";

let emit = defineEmits(["change", "update:checked"]);

let props = defineProps(["label", "checked", "light"]);

let { checked, label, light } = toRefs(props);

let handleClick = () => {
  let val = !checked?.value;
  emit("update:checked", val);
  emit("change", val);

  uni.vibrateShort({
    success: () => {
      //
    },
  });
};
</script>

<template>
  <div class="form-item">
    <span :class="light ? 'name name-light' : 'name'">{{ label }}</span>
    <div class="switch-wrap">
      <ComSwitchView @change="handleClick" :checked="checked" />
    </div>
  </div>
</template>

<style lang="less" scoped>
.form-item {
  display: flex;
  align-items: center;
  flex-direction: row;
  height: 112rpx;
}
.name {
  font-family: PingFangSC, PingFang SC;
  font-weight: bold;
  font-size: 32rpx;
  color: #333333;
  padding-right: 42rpx;
  padding-left: 34rpx;
}

.name-light {
  font-family: PingFangSC, PingFang SC;
  font-weight: 400;
  font-size: 32rpx;
  color: #333333;
}

.switch-wrap {
  flex: 1;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  padding-right: 30rpx;
}
</style>
